﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using Maticsoft.DBUtility;
using System.Data.SqlClient;

namespace ChinaSoft.DAL.Common
{
    public class PowerValidate
    {
        /// <summary>
        /// 根据传入的用户名和权限的ID来验证当前用户是否有权限
        /// 作者:demo
        /// 时间：2012-3-27
        /// </summary>
        /// <param name="UserAccount">用户名</param>
        /// <param name="PowerId">权限ID</param>
        /// <returns></returns>
        public static bool ValidatePower(string UserAccount, int PowerId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from V_RolePower");
            strSql.Append(" where UserAccount=@UserAccount and PowerId=@PowerId");
            SqlParameter[] parameters = {
					new SqlParameter("@UserAccount", SqlDbType.NVarChar,20),
                    new SqlParameter("@PowerId",SqlDbType.Int,4)
			};
            parameters[0].Value =UserAccount;
            parameters[1].Value = PowerId;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }
    }
}
